<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/common/hplus-css.jsp"%>
    <title>修改用户头像</title>
</head>
<body>
     <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox">
                    <div class="ibox-content" style="border: 0px;">
                        <form class="form-horizontal m-t" id="userForm" method="post" enctype="multipart/form-data">
                            <input id="id" name="id" type="hidden" value="${user.id}" />
                             <div class="form-group">
                                <label class="col-sm-3 control-label">请选择头像：</label>
                                <div class="col-sm-5">
                                   	<input type="file" class="form-control" name="headImg_" id="headImg_" required="" onchange="uploadImageCallbak(this,'1','userForm',imageCallBak)"/>
                                	<input type="hidden" name="headImg" id="headImg"/>
                               		<img id="imageView" src="${user.headImg }" style="height:340px;width:423px;<c:if test='${empty user.headImg }'>display: none;</c:if>"/>
                                </div>
                            </div>
                       </form>
                           
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" id="update-btn" type="button">提交</button>                             
                            </div>
                        </div>
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@include file="/WEB-INF/common/hplus-js.jsp"%>
    <script type="text/javascript">
 		
        $(document).ready(function () {
            
            $("#update-btn").click(function(){
            	
	           var headImg = $("#headImg").val();
            	if(headImg == null || headImg == "") {
            		swal("请选择头像照片");
            	}
            	
            	$("#userForm").ajaxSubmit({
        			url : "${path }/user/updateEditHeaderImg",
        			type : "post",
        			dataType : "json",
        			data:{time:Math.random() },
        			timeout : 60000,
        			success : function(data, textStatus) {
        				swal(data.msg);
        			},error : function(data, textStatus) {
        				swal(data.msg);
        			}
        		});
            });
        });
        
        function imageCallBak(data) {
        	$("#imageView").attr("src",data.path);
        }
    </script>
</body>
</html>
